#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
using namespace std;

enum FiregunStatus
{
    NO_GUN = 0,
    HAS_GUN,
    INVALID
};

void putFiregun(int n, const char* city);
bool checkValidation(int n, const char* city, const short* pos, int posIndex);
int countFiregun(int n, const short* pos);
void display(int maxCount);

#define READ_FILE

int main()
{
    int n;
    char city[4 * 4];

#ifdef READ_FILE
    ifstream readIn("1002.input");
	if (!readIn)
	{
		readIn.open("../1002.input");
	}
#else
#define readIn cin
#endif
    
    while (1)
    {
        readIn >> n;
        if (n == 0)
        {
            break;
        }

        memset(city, 0, sizeof(city));
        for (int i = 0; i < n * n; i++)
        {
            readIn >> city[i];
        }

        putFiregun(n, city);
    }

#ifdef READ_FILE
    readIn.close();
#endif

    return 0;
}

void putFiregun(int n, const char* city)
{
    short pos[4 * 4];

    short maxCount = 0;

    memset(pos, 0, sizeof(pos));

    int size = n * n;
    int posIndex = 0;

    while (pos[0] != INVALID)
    {
        if (pos[posIndex] == INVALID)
        {
            pos[--posIndex]++;
            continue;
        }

        if (checkValidation(n, city, pos, posIndex))
        {
            if (posIndex == size - 1)
            {
                int firegunCount = countFiregun(n, pos);
                if (maxCount < firegunCount)
                {
                    maxCount = firegunCount;
                }
                pos[posIndex]++;
            }
            else
            {
                pos[++posIndex] = NO_GUN;
            }
        }
        else
        {
            pos[posIndex]++;
        }
    }

    display(maxCount);
}

bool checkValidation(int n, const char* city, const short* pos, int posIndex)
{
    if (pos[posIndex] == NO_GUN)
    {
        return true;
    }

    int line = posIndex / n;
    int row = posIndex % n;

    if (city[posIndex] == 'X')
    {
        return false;
    }

    int size = n * n;
    char* tmpCity = new char[size];
    memcpy(tmpCity, city, sizeof(char) * size);

    for (int i = 0; i <= posIndex; i++)
    {
        if (pos[i] == HAS_GUN)
        {
            tmpCity[i] = 'o';
        }
    }

    for (int line2 = line - 1; line2 >= 0; line2--)
    {
        int coord = line2 * n + row;
        if (tmpCity[coord] == 'X')
        {
            break;
        }
        else if (tmpCity[coord] == 'o')
        {
            return false;
        }
    }
    for (int line2 = line + 1; line2 < n; line2++)
    {
        int coord = line2 * n + row;
        if (tmpCity[coord] == 'X')
        {
            break;
        }
        else if (tmpCity[coord] == 'o')
        {
            return false;
        }
    }

    for (int row2 = row - 1; row2 >= 0; row2--)
    {
        int coord = line * n + row2;
        if (tmpCity[coord] == 'X')
        {
            break;
        }
        else if (tmpCity[coord] == 'o')
        {
            return false;
        }
    }
    for (int row2 = row + 1; row2 < n; row2++)
    {
        int coord = line * n + row2;
        if (tmpCity[coord] == 'X')
        {
            break;
        }
        else if (tmpCity[coord] == 'o')
        {
            return false;
        }
    }

    return true;
}

void display(int maxCount)
{
    cout << maxCount << endl;
}

int countFiregun(int n, const short* pos)
{
    int sum = 0;
    for (int i = 0; i < n * n; i++)
    {
        if (pos[i] == HAS_GUN)
        {
            sum++;
        }
    }
    return sum;
}
